// User相关api
import type { CodeType, Patient, User, UserInfo } from '@/types/user'
import { request } from '@/utils/request'

// 密码登录
export const loginApi = (mobile: string, password: string) => {
  return request<User>('login/password', 'post', { mobile, password })
}

// 获取验证码
export const getCodeApi = (mobile: string, type: CodeType) => {
  return request('code', 'get', { mobile, type })
}

// 验证码登录
export const loginCodeApi = (mobile: string, code: string) => {
  return request<User>('login', 'post', { mobile, code })
}
// 获取用户详细信息
export const getUserInfoApi = () => {
  return request<UserInfo>('patient/myUser')
}

// 获取家庭患者列表
export const getPatientListApi = () => {
  return request<Patient[]>('patient/myList')
}

// 添加患者
export const addPatientApi = (patient: Patient) => {
  return request('patient/add', 'post', patient)
}

// 编辑患者
export const editPatientApi = (patient: Patient) => {
  return request('patient/update', 'put', patient)
}
// 删除患者
export const deletePatientApi = (id: string) => {
  return request(`patient/del/${id}`, 'delete')
}

// 查询患者详情
export const getPatientDetail = (id: string) => request<Patient>(`/patient/info/${id}`)

//展示未读消息数量
export const getUnreadMessageCount = () => {
  return request<number>('patient/message/unRead/all')
}

// 提交评价
export const evaluateConsultOrder = (data: {
  docId: string
  orderId: string
  score: number
  content: string
  anonymousFlag: 0 | 1
}) => request<{ id: string }>('/patient/order/evaluate', 'POST', data)
